from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.edge.service import Service
from webdriver_manager.microsoft import EdgeChromiumDriverManager
from time import sleep

# #浏览器搜索自动化脚本
#
# #1.打开浏览器
# EdgeIns = EdgeChromiumDriverManager().install()
# ##创建驱动对象
# driver = webdriver.Edge(service=Service(EdgeIns))
# sleep(3)
#
# #2.输入百度网址
# driver.get("http://www.baidu.com")
# sleep(3)
#
# #3.打开搜索栏搜索“csdn”
# driver.find_element(By.CSS_SELECTOR,"#kw").send_keys("CSDN")
# sleep(3)
#
# #4.点击“白度一下”按钮
# driver.find_element(By.CSS_SELECTOR,"#su").click()
# sleep(5)
#
# #5.关闭浏览器
# driver.quit()

#找热搜

#1.打开浏览器
EdgeIns = EdgeChromiumDriverManager().install()
##创建驱动对象
driver = webdriver.Edge(service=Service(EdgeIns))

#2.输入百度网址
driver.get("http://www.baidu.com")

#3.查找页面热搜
ret = driver.find_elements(By.CSS_SELECTOR,"#hotsearch-content-wrapper > li")

#4.循环打印内容
for i in ret:
    print(i.text)

#5.关闭浏览器
driver.quit()
